package csdn;

//class Animal{
//    public String name;
//    public Animal(String name){
//        this.name=name;
//    }
//    public void eat(String food){
//        System.out.println(this.name+"正在干饭,并表示"+food+"很不错");
//    }
//}
//class Dog extends Animal{
//    public Dog(String name){
//        super(name);
//    }
//    @Override
//    public void eat(String food) {
//        System.out.println(this.name+"在吃"+food);
//    }
//}

class Animal {
    public String name;
    public Animal(String name) {
        this.name = name;
    }
    public void eat(String food) {
        System.out.println("我是一只小动物");
        System.out.println(this.name+"正在干饭,并表示"+food+"很不错");
    }
}
// Cat.java
class Cat extends Animal{
    public Cat(String name) {
        super(name);
    }
    @Override
    public void eat(String food) {
        System.out.println("我是一只小猫");
        System.out.println(this.name+"正在干饭,并表示"+food+"很不错");
    }
}
// Bird.java
class Bird extends Animal{
    public Bird(String name) {
        super(name);
    }
    @Override
    public void eat(String food) {
        System.out.println("我是一只小鸟");
        System.out.println(this.name+"正在干饭,并表示"+food+"很不错");
    }

    public void fly() {
        System.out.println(this.name + "正在飞 ︿(￣︶￣)︿");
    }
}
public class Csdn4 {
    public static void main(String[] args) {
        Animal animal2 = new Bird("扁扁");
        Bird bird = (Bird)animal2;
        bird.fly();
    }
}
